﻿using CommonEntity.CPUEntity;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CPUAPI.Context
{
    public class CPUContext : DbContext
    {
        public CPUContext(DbContextOptions<CPUContext> options)
           : base(options)
        {

        }

        public DbSet<CPUInfo> CPUInfos { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            //初始化数据
            modelBuilder.Entity<CPUInfo>().HasData(new CPUInfo
            {
                ID = 1,
                Name = "海思麒麟",
                LastProduceTime = DateTime.Now,
                TotalCount = 10
            },
            new CPUInfo
            {
                ID = 2,
                Name = "联发科",
                LastProduceTime = DateTime.Now,
                TotalCount = 10
            },
            new CPUInfo
            {
                ID = 3,
                Name = "高通晓龙",
                LastProduceTime = DateTime.Now,
                TotalCount = 10
            },
            new CPUInfo
            {
                ID = 4,
                Name = "苹果A系列",
                LastProduceTime = DateTime.Now,
                TotalCount = 10
            });
        }
    }
}
